﻿package export.huodong.newyear
{
	import com.dusk.net.ServerConnect;
	import com.dusk.util.RandomUtil;
	import com.dusk.util.TimeUtil;
	import com.game.manager.NotificationManager;
	
	import config.Config;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.utils.getDefinitionByName;
	
	public class ChineseNewYear extends Sprite
	{
		
		public static function generateRedPack():void
		{
			/*var gc:Config = getDefinitionByName("config::Config").I;
			var awardList:Array = [["wpxt", "wptm", "wpsc"], ["jf", "xhb"], ["wpxm", "wpll", "wplh", "wpsg", "yhs", "tss"], ["gfcstx", "_ssggjtg", "lsg"]];
			var level:int;
			var num:int = 1;
			var item:*;
			if (RandomUtil.randBoolean(0.05))
			{
				level = 3;
				num = 1;
				item = gc.allEquip.findByName(awardList[level][Math.round(Math.random() * (awardList[level].length - 1))]);
				gc.player1.equipList.push(item);
				NotificationManager.alert("恭喜获得" + item.ename + " x 1!");
			}
			else if (RandomUtil.randBoolean(3))
			{
				level = 2;
				num = Math.round(Math.random() * 2);
				item = awardList[level][(Math.round(Math.random() * (awardList[level].length - 1)))];
				if (gc.player1.roleId > 0)
				{
					gc.putQhsInBackPack(gc.player1, item, num);
				}
				if (gc.player2.roleId > 0)
				{
					gc.putQhsInBackPack(gc.player2, item, num);
				}
				NotificationManager.alert("恭喜获得" + gc.allEquip.findByName(item).name + " x 1!");
			}
			else if (RandomUtil.randBoolean(8))
			{
				level = 1;
				if (RandomUtil.randBoolean(50))
				{
					num = 20 + Math.round(Math.random() * 5);
					gc.userData.turnTableScore += num;
					NotificationManager.alert("恭喜获得" + num + "积分！");
				}
				else
				{
					num = 2 + Math.round(Math.random() * 5);
					if (gc.player1.roleId > 0)
					{
						gc.putQhsInBackPack(gc.player1, "xhb", num);
					}
					if (gc.player2.roleId > 0)
					{
						gc.putQhsInBackPack(gc.player2, "xhb", num);
					}
					NotificationManager.alert("恭喜获得" + num + "仙魂币！");
				}
			}
			else
			{
				level = 0;
				num = 15 + Math.round(Math.random() * 40);
				item = awardList[level][(Math.round(Math.random() * (awardList[level].length - 1)))];
				if (gc.player1.roleId > 0)
				{
					gc.putQhsInBackPack(gc.player1, item, num);
				}
				if (gc.player2.roleId > 0)
				{
					gc.putQhsInBackPack(gc.player2, item, num);
				}
				NotificationManager.alert("恭喜获得" + gc.allEquip.findByName(item).name + " x " + num + "!");
			}
			gc.memory.saveGame(gc.saveId, false);*/
		}
		
		public function ChineseNewYear()
		{
			super();
		}
		
		public static function getRedPack(param1:MouseEvent):void
		{
			if(ServerConnect.getServerDate() == TimeUtil.getCurrentDate())
			{
				ChineseNewYear.generateRedPack()
			}
			else
			{
				NotificationManager.alert("请勿修改时间刷红包！");
			}
		}
	}
}
